/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.wins.vertx.entity;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

/**
 * Converter for {@link io.wins.vertx.entity.Customer}.
 *
 * NOTE: This class has been automatically generated from the {@link io.wins.vertx.entity.Customer} original class using Vert.x codegen.
 */
public class CustomerConverter {

  public static void fromJson(JsonObject json, Customer obj) {
    if (json.getValue("birthday") instanceof String) {
      obj.setBirthday((String)json.getValue("birthday"));
    }
    if (json.getValue("createdOn") instanceof Number) {
      obj.setCreatedOn(((Number)json.getValue("createdOn")).longValue());
    }
    if (json.getValue("delete") instanceof Boolean) {
      obj.setDelete((Boolean)json.getValue("delete"));
    }
    if (json.getValue("description") instanceof String) {
      obj.setDescription((String)json.getValue("description"));
    }
    if (json.getValue("email") instanceof String) {
      obj.setEmail((String)json.getValue("email"));
    }
    if (json.getValue("image") instanceof String) {
      obj.setImage((String)json.getValue("image"));
    }
    if (json.getValue("loginId") instanceof String) {
      obj.setLoginId((String)json.getValue("loginId"));
    }
    if (json.getValue("nickname") instanceof String) {
      obj.setNickname((String)json.getValue("nickname"));
    }
    if (json.getValue("phone") instanceof String) {
      obj.setPhone((String)json.getValue("phone"));
    }
    if (json.getValue("realName") instanceof String) {
      obj.setRealName((String)json.getValue("realName"));
    }
    if (json.getValue("sex") instanceof Boolean) {
      obj.setSex((Boolean)json.getValue("sex"));
    }
    if (json.getValue("updatedOn") instanceof Number) {
      obj.setUpdatedOn(((Number)json.getValue("updatedOn")).longValue());
    }
  }

  public static void toJson(Customer obj, JsonObject json) {
    if (obj.getBirthday() != null) {
      json.put("birthday", obj.getBirthday());
    }
    json.put("createdOn", obj.getCreatedOn());
    json.put("delete", obj.isDelete());
    if (obj.getDescription() != null) {
      json.put("description", obj.getDescription());
    }
    if (obj.getEmail() != null) {
      json.put("email", obj.getEmail());
    }
    if (obj.getId() != null) {
      json.put("id", obj.getId());
    }
    if (obj.getImage() != null) {
      json.put("image", obj.getImage());
    }
    if (obj.getLoginId() != null) {
      json.put("loginId", obj.getLoginId());
    }
    if (obj.getNickname() != null) {
      json.put("nickname", obj.getNickname());
    }
    if (obj.getPhone() != null) {
      json.put("phone", obj.getPhone());
    }
    if (obj.getRealName() != null) {
      json.put("realName", obj.getRealName());
    }
    json.put("sex", obj.isSex());
    json.put("updatedOn", obj.getUpdatedOn());
  }
}